package com.yipei.business.controller;

import com.yipei.business.domain.MlBtsPointImport;
import com.yipei.business.service.IMlBtsPointImportService;
import com.yipei.common.annotation.Log;
import com.yipei.common.core.controller.BaseController;
import com.yipei.common.core.domain.AjaxResult;
import com.yipei.common.core.page.TableDataInfo;
import com.yipei.common.enums.BusinessType;
import com.yipei.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 导入BTSController
 *
 * @author yipei
 * @date 2024-12-21
 */
@RestController
@RequestMapping("/business/import")
@Api(tags = "导入BTS", description = "导入BTS管理")
public class MlBtsPointImportController extends BaseController {
    @Autowired
    private IMlBtsPointImportService mlBtsPointImportService;

    /**
     * 查询导入BTS列表
     */
    //@PreAuthorize("@ss.hasPermi('business:import:list')")
    @ApiOperation("导入BTS获取数据")
    @GetMapping("/list")
    public TableDataInfo list(MlBtsPointImport mlBtsPointImport) {
        startPage();
        List<MlBtsPointImport> list = mlBtsPointImportService.selectMlBtsPointImportList(mlBtsPointImport);
        return getDataTable(list);
    }

    /**
     * 导出导入BTS列表
     */
    //@PreAuthorize("@ss.hasPermi('business:import:export')")
    @ApiOperation("导入BTS导出数据")
    @Log(title = "导入BTS", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MlBtsPointImport mlBtsPointImport) {
        List<MlBtsPointImport> list = mlBtsPointImportService.selectMlBtsPointImportList(mlBtsPointImport);
        ExcelUtil<MlBtsPointImport> util = new ExcelUtil<MlBtsPointImport>(MlBtsPointImport.class);
        util.exportExcel(response, list, "导入BTS数据");
    }

    /**
     * 获取导入BTS详细信息
     */
    //@PreAuthorize("@ss.hasPermi('business:import:query')")
    @ApiOperation("导入BTS通过ID获取数据")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mlBtsPointImportService.selectMlBtsPointImportById(id));
    }

    /**
     * 新增导入BTS
     */
    //@PreAuthorize("@ss.hasPermi('business:import:add')")
    @ApiOperation("导入BTS新增数据")
    @Log(title = "导入BTS", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MlBtsPointImport mlBtsPointImport) {
        return toAjax(mlBtsPointImportService.insertMlBtsPointImport(mlBtsPointImport));
    }

    /**
     * 修改导入BTS
     */
    //@PreAuthorize("@ss.hasPermi('business:import:edit')")
    @ApiOperation("导入BTS修改数据")
    @Log(title = "导入BTS", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MlBtsPointImport mlBtsPointImport) {
        return toAjax(mlBtsPointImportService.updateMlBtsPointImport(mlBtsPointImport));
    }

    /**
     * 删除导入BTS
     */
    //@PreAuthorize("@ss.hasPermi('business:import:remove')")
    @ApiOperation("导入BTS删除数据")
    @Log(title = "导入BTS", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mlBtsPointImportService.deleteMlBtsPointImportByIds(ids));
    }
}
